{extend name="base" /}
{block name="body"}
<div class="layui-body">
    <!--tab标签-->
    <div class="layui-tab layui-tab-brief">
        <ul class="layui-tab-title">
            <li class=""><a href="{:url('admin/newsflash/com_list','id='.$id)}">评论列表</a></li>
            <li class="layui-this">添加评论</li>
        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">
                <form class="layui-form form-container" action="{:url('admin/newsflash/com_save')}" method="post">
                    <input type="hidden" name="news_flash_id" value="{$id}">
                    <div class="layui-form-item">
                        <label class="layui-form-label">头像</label>
                        <div class="layui-input-block">
                            <input type="text" name="img" value=""lay-verify="required" class="layui-input layui-input-inline" id="picture">
                            <input type="file" name="image" lay-type="images" class="layui-upload-file">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">评论人</label>
                        <div class="layui-input-block">
                            <input type="text" name="user" value="" required  lay-verify="required" placeholder="请输入评论人名字" class="layui-input">
                        </div>
                    </div>

                    <div class="layui-form-item layui-form-text">
                        <label class="layui-form-label">评论内容</label>
                        <div class="layui-input-block">
                            <textarea name="content" placeholder="请输入内容" class="layui-textarea"></textarea>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">评论时间</label>
                        <div class="layui-input-inline">
                            <input class="layui-input date"  placeholder="yyyy-MM-dd HH:mm:ss" name="add_time" value="{:date('Y-m-d H:i:s',time())}" type="text">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">评论状态</label>
                        <div class="layui-input-block">
                            <input type="radio" name="status" value="0" title="隐藏"checked="checked">
                            <input type="radio" name="status" value="1" title="显示">

                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">置顶设置</label>
                        <div class="layui-input-block">
                            <input type="radio" name="is_up" value="0" title="不置顶" checked="checked">
                            <input type="radio" name="is_up" value="1" title="置顶">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn jch" lay-submit lay-filter="*">保存</button>
                            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
{/block}
{block name="js"}
<script src="__JS__/ueditor/ueditor.config.js"></script>
<script src="__JS__/ueditor/ueditor.all.min.js"></script>
{/block}
{block name="script"}
<script>


    $(function() {

        layui.upload({
            url: "/api/file_upload/upload",
            success: function (data) {
                if (data.error === 0 && data.type === 'image') {
                    document.getElementById('picture').value = data.url;
                } else {
                    layer.msg(data.message);
                }
            }
        });

        $('.date').on('click', function () {
            laydate({
                elem: this
                ,format: 'YYYY-MM-DD hh:mm:ss'
                ,type: 'datetime'
            })
        });
    });


    $('.jch').click(function () {

        var img = $('input[name="img"]').val();
        if(!img){
            layer.alert("请上传头像",{icon:2});
            return false;
        }

        var user = $('input[name="user"]').val();
        if(!user){
            layer.alert("评论人不能为空",{icon:2});
            return false;
        }

        var content = $('textarea[name="content"]').val();
        if(!content){
            layer.alert("请输入评论内容",{icon:2});
            return false;
        }


    });

</script>
{/block}